package com.oak.broke.model.vip.base;

import lombok.Data;

import java.util.List;

/**
 * @author tanghan
 * @email broke@gmail.com
 * @date 2023-04-12 17:02:57
 */
@Data
public class PageUtil<T> {

    /**
     * 总记录数
     */
    private int total;

    /**
     * 每页记录数
     */
    private int pageSize;

    /**
     * 总页数
     */
    private int totalPage;

    /**
     * 当前页数
     */
    private int currPage;

    /**
     * 记录
     */
    private List<T> records;

    /**
     * 分页
     *
     * @param records    列表数据
     * @param total 总记录数
     * @param pageSize   每页记录数
     * @param currPage   当前页数
     */
    public PageUtil(List<T> records, int total, int pageSize, int currPage) {
        this.records = records;
        this.total = total;
        this.pageSize = pageSize;
        this.currPage = currPage;
        this.totalPage = (int) Math.ceil((double) total / pageSize);
    }
}
